/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.token.web.dto;

import java.io.Serializable;

import com.opgea.token.domain.entities.Destination;
import com.opgea.token.domain.interfaces.Marshallable;

/**
 * 
 * @author Ramesh
 */
public class DestinationDTO implements Serializable, Marshallable<Destination> {

    private static final long serialVersionUID = -7199633451626071303L;
    private Long id;
    private String name;
    private Long companyId;

    public DestinationDTO() {
    }

    public DestinationDTO(Long id, String name, Long companyId) {
	this.id = id;
	this.name = name;
	this.companyId = companyId;
    }

    public Long getId() {
	return id;
    }

    public void setId(Long id) {
	this.id = id;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public Long getCompanyId() {
	return companyId;
    }

    public void setCompanyId(Long companyId) {
	this.companyId = companyId;
    }

    /**
     * Copy values from Destination entity to DestinationDTO.
     */
    @Override
    public void marshall(Destination object) {
	this.id = object.getId();
	this.name = object.getName();
	if (object.getCompany() != null) {
	    this.companyId = object.getCompany().getId();
	}
    }

    /**
     * Copy values from DestinationDTO to Destination entity.
     */
    @Override
    public Destination unmarshall(Destination object) {
	if (this.id > 0) {
	    object.setId(this.id);
	}
	object.setName(this.name);
	if (object.getCompany() != null) {
	    object.getCompany().setId(this.companyId);
	}
	return object;
    }
}
